package org.codeCard.model;

import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;
import org.cbg.btn.CBGDahuabiBuyBtn;
import org.codeCard.bean.TbSaleCardOrder;
import org.come.until.CutButtonImage;
import org.come.until.Util;

import javax.swing.*;
import java.awt.*;
import java.math.BigDecimal;



public class CodeCardSellerModel extends JPanel {
    // 展示底框 展示图标 大话币上 大话币下 价格 单价
    private JLabel zhanshidikuang, tupian, dahuabishang, dianka, zongjia, danjia;

    // 购买button
    private CBGDahuabiBuyBtn buy;

    /**
     * 是否被收藏标识(0表示被收藏，1表示没有被收藏) 公示期标识(0 在公示期 ， 1上架)
     */
    private int stateOrNo = 1, gongshiqiBiaoshi = 0;

    private TbSaleCardOrder currtSalegoods;

    public CodeCardSellerModel() {
        /**
         * 面板设置
         */
        this.setLayout(null);
        this.setPreferredSize(new Dimension(400, 30));
        this.setOpaque(false);

        tupian = new JLabel();
        zhanshidikuang = new JLabel();
        dahuabishang = new JLabel("大话币");
        dianka = new JLabel("240000");
        zongjia = new JLabel("4800000000");

        zhanshidikuang.setBorder(null);
        zhanshidikuang.setBounds(40, 0, 30, 30);
        zhanshidikuang.setIcon(CutButtonImage.getImage("inkImg/background/10.png", 30, 30));
        zhanshidikuang.setOpaque(false);
        this.add(zhanshidikuang);

        danjia = new JLabel("100000.0");
        dahuabishang.setFont(UIUtils.TEXT_FONT);
        dahuabishang.setForeground(Color.white);
        dianka.setFont(UIUtils.TEXT_FONT);
        dianka.setForeground(Color.white);
        dianka.setHorizontalAlignment(SwingConstants.CENTER);
        zongjia.setFont(UIUtils.TEXT_FONT);
        zongjia.setForeground(Color.white);
        zongjia.setHorizontalAlignment(SwingConstants.CENTER);
        danjia.setFont(UIUtils.TEXT_FONT);
        danjia.setForeground(Color.white);
        danjia.setHorizontalAlignment(SwingConstants.CENTER);


        if (MyIsif.getStyle().equals("水墨UI")) {
            tupian.setBounds(60, 0, 39, 39);
            dahuabishang.setBounds(155, -5, 100, 24);
            dianka.setBounds(90, 8, 50, 24);
            danjia.setBounds(160, 0, 125, 40);
            zongjia.setBounds(300, 0, 125, 40);
        }else{
            tupian.setBounds(40, 0, 39, 39);
            dahuabishang.setBounds(155, -5, 100, 24);
            dianka.setBounds(70, 8, 50, 24);
            danjia.setBounds(140, 0, 125, 40);
            zongjia.setBounds(300, 0, 125, 40);
        }


        tupian.setIcon(CutButtonImage.getImage("inkImg/number/b9/小点卡.png", 30, 30));


        this.add(tupian);
        this.add(dianka);
        this.add(zongjia);
        this.add(danjia);


    }


    /**
     * 添加数据  单行数据
     *
     * @param salegoods
     */
    public CodeCardSellerModel(TbSaleCardOrder salegoods) {
        this.currtSalegoods = salegoods;
        this.setLayout(null);
        this.setPreferredSize(new Dimension(400, 30));
        this.setOpaque(false);

        tupian = new JLabel();
        zhanshidikuang = new JLabel();
        dahuabishang = new JLabel("大话币");
        dianka = new JLabel(salegoods.getCardCode().toString());
        zongjia = new JLabel(salegoods.getSalePrice().toString());

        zhanshidikuang.setBorder(null);
        if (MyIsif.getStyle().equals("水墨UI")) {
            zhanshidikuang.setBounds(20, 0, 30, 30);
        }else{
            zhanshidikuang.setBounds(20, 0, 30, 30);

        }
        zhanshidikuang.setIcon(CutButtonImage.getImage("inkImg/number/b9/10.png", 30, 30));
        zhanshidikuang.setOpaque(false);

        this.add(zhanshidikuang);
        BigDecimal meidian = salegoods.getSalePrice().divide(salegoods.getCardCode(),BigDecimal.ROUND_HALF_UP);
        danjia = new JLabel(meidian.toString());
        dahuabishang.setFont(UIUtils.TEXT_FONT1);
        dahuabishang.setForeground(Color.white);
        dianka.setFont(UIUtils.TEXT_FONT1);
        dianka.setForeground(Color.white);
        dianka.setHorizontalAlignment(SwingConstants.CENTER);
        zongjia.setFont(UIUtils.TEXT_FONT1);

        Util.changeJLabelTextColor(zongjia, salegoods.getSalePrice());
        zongjia.setHorizontalAlignment(SwingConstants.CENTER);
        danjia.setFont(UIUtils.TEXT_FONT1);

        Util.changeJLabelTextColor(danjia, meidian);
        danjia.setHorizontalAlignment(SwingConstants.CENTER);


        if (MyIsif.getStyle().equals("水墨UI")) {
            dahuabishang.setBounds(155, -5, 100, 24);
            dianka.setBounds(50, 8, 50, 24);
            danjia.setBounds(120, 0, 125, 40);
            tupian.setBounds(20, 0, 39, 39);
            zongjia.setBounds(260, 0, 125, 40);
        }else{
            dahuabishang.setBounds(155, -5, 100, 24);
            dianka.setBounds(70, 8, 50, 24);
            danjia.setBounds(120, 0, 125, 40);
            tupian.setBounds(20, 0, 39, 39);
            zongjia.setBounds(250, 0, 125, 40);
        }

        tupian.setIcon(CutButtonImage.getImage("inkImg/number/b9/小点卡.png", 30, 30));


        this.add(tupian);
        this.add(dianka);
        this.add(zongjia);
        this.add(danjia);

    }


    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);

    }


    public JLabel getZhanshidikuang() {
        return zhanshidikuang;
    }

    public void setZhanshidikuang(JLabel zhanshidikuang) {
        this.zhanshidikuang = zhanshidikuang;
    }

    public JLabel getTupian() {
        return tupian;
    }

    public void setTupian(JLabel tupian) {
        this.tupian = tupian;
    }

    public JLabel getDahuabishang() {
        return dahuabishang;
    }

    public void setDahuabishang(JLabel dahuabishang) {
        this.dahuabishang = dahuabishang;
    }

    public JLabel getDianka() {
        return dianka;
    }

    public void setDianka(JLabel dianka) {
        this.dianka = dianka;
    }

    public JLabel getZongjia() {
        return zongjia;
    }

    public void setZongjia(JLabel zongjia) {
        this.zongjia = zongjia;
    }

    public JLabel getDanjia() {
        return danjia;
    }

    public void setDanjia(JLabel danjia) {
        this.danjia = danjia;
    }

    public CBGDahuabiBuyBtn getBuy() {
        return buy;
    }

    public void setBuy(CBGDahuabiBuyBtn buy) {
        this.buy = buy;
    }

    public int getGongshiqiBiaoshi() {
        return gongshiqiBiaoshi;
    }

    public void setGongshiqiBiaoshi(int gongshiqiBiaoshi) {
        this.gongshiqiBiaoshi = gongshiqiBiaoshi;
    }

    public ImageIcon getIcon() {
        return icon;
    }

    public void setIcon(ImageIcon icon) {
        this.icon = icon;
    }

    public int getStateOrNo() {
        return stateOrNo;
    }

    public void setStateOrNo(int stateOrNo) {
        this.stateOrNo = stateOrNo;
    }

    public TbSaleCardOrder getCurrtSalegoods() {
        return currtSalegoods;
    }

    public void setCurrtSalegoods(TbSaleCardOrder currtSalegoods) {
        this.currtSalegoods = currtSalegoods;
    }


}
